<template>
  <!-- 套餐核销记录 -->
  <section>
    <div style="border-bottom:1px solid #eee;padding-bottom:10px;">
      <el-page-header @back="goBack" content="套餐核销记录">
      </el-page-header>
    </div>
    <br>
    <el-form :inline="true" @submit.native.prevent="getData">
      <el-form-item>
        <el-select v-model="form.finished" placeholder="使用状态">
          <el-option :value="0" label="未使用完 "></el-option>
          <el-option :value="1" label="使用完  "></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" circle icon="el-icon-search" native-type="submit"></el-button>
      </el-form-item>
    </el-form>
    <table class="table-box">
      <thead>
        <tr>
          <th>订单流水号</th>
          <th>套餐</th>
          <th>项目</th>
          <th>收费核销人员</th>
          <th>使用状态</th>
          <th>创建时间</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in tableList" :key="index">
          <td>{{item.transNo}}</td>
          <td>{{item.packageName}}</td>
          <td>{{item.packageItemName}}</td>
          <td>{{item.memberName}}</td>
          <td>{{item.finished==1?"使用完":"未使用完"}}</td>
          <td>{{item.gmtCreate}}</td>
          <td style=" white-space:nowrap;">
            <el-link type="primary" @click="onOpenEdit(item)">查看</el-link>
          </td>
        </tr>
      </tbody>
    </table>
    <div v-if="tableList.length == 0" style="color:#999;padding:10px 0;text-align:center;">
      <i class="iconfont iconwushuju" style="font-size:40px;"></i>
      <div>暂无数据</div>
    </div>
    <br>
    <pager v-model="pager" @change-pagenum="getData"></pager>
    <groupObjRecordDetail v-model="dialogDetail" :curItem="curItem"></groupObjRecordDetail>
  </section>
</template>
<script>
// 传入参数patientId加密
export default {
  components: {
    groupObjRecordDetail: () => import("./_com/groupObjRecordDetail.vue")
  },
  data() {
    return {
      curItem: null,
      dialogDetail: false,
      form: {
        finished: "",
        patientId: ""
      },
      tableList: [],
      pager: { pageSize: 20, pageNum: 1, total: 0 }
    };
  },
  mounted() {
    const th = this;
    th.form.patientId = th.jieMi(th.$route.query.patientId);
    th.getData();
  },
  methods: {
    onOpenEdit(obj) {
      const th = this;
      th.curItem = obj;
      th.dialogDetail = true;
    },
    goBack() {
      const th = this;
      th.$router.go(-1);
    },
    getData(type) {
      let th = this;
      if (type == -1) {
        th.pager.pageNum = 1;
        th.pager.total = 0;
      }
      let j = {};
      Object.assign(j, th.pager);
      Object.assign(j, th.form);
      th.$api.findUserPackageUseRecordAll(j).then(res => {
        if (res.executed) {
          th.tableList = res.dataBody.list;
          th.pager.total = res.dataBody.total;
        }
      });
    }
  }
};
</script>